<?php
$Basedir = dirname(__FILE__);
$field_id = rex_request('field_id', 'int');
$id = rex_request('id', 'int');

//------------------------------> Eintragsliste
if ($func == '')
{
	$list = new rex_list('SELECT id,car_hersteller,car_modell,car_farbe,car_erstzulassung,car_preis FROM rex_351_cars',50);
	
	$imgHeader = '<a href="'. $list->getUrl(array('func' => 'add')) .'"><img src="media/metainfo_plus.gif" alt="add" title="add" /></a>';
	
	$list->setColumnSortable('car_hersteller');
	$list->setColumnSortable('car_modell');
	$list->setColumnSortable('car_farbe');
	$list->setColumnSortable('car_erstzulassung');
	$list->setColumnSortable('car_preis');

	$list->addColumn(	$imgHeader, 
						'<img src="media/metainfo.gif" alt="field" title="field" />', 
						0, 
						array('<th class="rex-icon">###VALUE###</th>',
								'<td class="rex-icon">###VALUE###</td>')
					);					
	$list->setColumnParams	(	$imgHeader, 
								array('func' => 'edit', 'id' => '###id###')
							);
	
	
	$list->setColumnLabel('id', "ID");
	$list->setColumnLabel('car_hersteller', 'Hersteller');	
	$list->setColumnLabel('car_modell', 'Modell');
	$list->setColumnLabel('car_farbe', 'Farbe');
	$list->setColumnLabel('car_erstzulassung', 'Erstzulassung');
	$list->setColumnLabel('car_preis', 'Preis');
	
	$list->setColumnLayout	(	'id',
								array('<th class="rex-icon">###VALUE###</th>','<td class="rex-icon">###VALUE###</td>')
							);
	$list->setColumnParams('car_modell', array('func' => 'edit', 'id' => '###id###'));
	$list->show();
}
//------------------------------> Formular
elseif ($func == 'edit' || $func == 'add')
{	$form = new a351_rex_form('rex_351_cars',"Allgemein","id=".$id,"post",false);

	#############################################
	# Allgemein
	$field = &$form->addTextField('car_hersteller');
    $field->setLabel("Hersteller");
    	
	$field = &$form->addTextField('car_modell');
    $field->setLabel("Modell");
	
	$field = &$form->addTextField('car_farbe');
    $field->setLabel("Farbe");

	$field = &$form->addTextField('car_erstzulassung');
    $field->setLabel("Erstzulassung");
	
	$field = &$form->addTextField('car_preis');
    $field->setLabel("Preis (EUR)");
	 
	#############################################
	# Bilder  
	$form->addFieldSet('Bilder');
	
	$field = &$form->addMediaField('car_bild1');
	$field->setLabel("");	
	$field->setPrefix('<label>Hauptbild</label>');
		
	$field = &$form->addMediaField('car_bild2');
	$field->setLabel("");	
	$field->setPrefix('<label>Bild 2</label>');
	    
	$field = &$form->addMediaField('car_bild3');
	$field->setLabel("");
	$field->setPrefix('<label>Bild 3</label>');
	
	$field = &$form->addMediaField('car_bild4');
	$field->setLabel("");
	$field->setPrefix('<label>Bild 4</label>');
	
	$field->setSuffix('<br style="clear:both;" />');
	
		
	if($func == 'edit')
    {	$form->addParam('id', $id);
    }
	
	#############################################
	# Abmessungen 
	$form->addFieldSet('Abmessungen');
	
	$field = &$form->addTextField('car_abmessungen_radstand');
    $field->setLabel("Radstand - mm");
	
	$field = &$form->addTextField('car_abmessungen_laenge_breite_hoehe');
    $field->setLabel("L&auml;nge / Breite / H&ouml;he - mm");
	
	$field = &$form->addTextField('car_abmessungen_spurweite');
    $field->setLabel("Spurweite vorn / hinten - mm");
	$field->setSuffix('<br style="clear:both;" />');
	
	#############################################
	# Leistung 
	$form->addFieldSet('Leistung');
	
	$field = &$form->addTextField('car_leistung_hoechstgeschwindigkeit');
    $field->setLabel("H&ouml;chstgeschwindigkeit - km/h");

	$field = &$form->addTextField('car_leistung_beschleunigung');
    $field->setLabel("Beschleunigung 0-100 km/h-s");

	$field = &$form->addTextField('car_leistung_innerorts');
    $field->setLabel("Innerorts - l/100km");

	$field = &$form->addTextField('car_leistung_ausserorts');
    $field->setLabel("Au&szlig;erorts - l/100km");

	$field = &$form->addTextField('car_leistung_kombiniert');
    $field->setLabel("Kombiniert - l/100 km");

	$field = &$form->addTextField('car_leistung_co2');
    $field->setLabel("CO2- Emission - g/km");

	$field = &$form->addTextField('car_leistung_garantie');
    $field->setLabel("Garantie");

	$field = &$form->addTextField('car_leistung_typklasseneinstufung');
    $field->setLabel("Typklasseneinstufung - HP/VK/TK");
	
	$field = &$form->addTextField('car_leistung_serviceintervall');
    $field->setLabel("Serviceintervall");
	$field->setSuffix('<br style="clear:both;" />');
	
	#############################################
	# Fahrwerk 
	$form->addFieldSet('Fahrwerk');
	
	$field = &$form->addTextField('car_fahrwerk_antrieb');
    $field->setLabel("Antrieb");
	
	$field = &$form->addTextField('car_fahrwerk_getriebe');
    $field->setLabel("Getriebe");
	
	$field = &$form->addTextField('car_fahrwerk_bremsen');
    $field->setLabel("Bremsen - vorn &Oslash; mm");
	
	$field = &$form->addTextField('car_fahrwerk_reifen');
    $field->setLabel("Reifen");
	
	$field = &$form->addTextField('car_fahrwerk_raeder');
    $field->setLabel("R&auml;der");
	$field->setSuffix('<br style="clear:both;" />');
	
	#############################################
	# Gewichte 
	$form->addFieldSet('Gewichte');

	$field = &$form->addTextField('car_gewichte_kraftstoffbehaelter');
    $field->setLabel("Kraftstoffbeh&auml;lter");

	$field = &$form->addTextField('car_gewichte_leergewicht');
    $field->setLabel("Leergewicht (inkl. Fahrer 75 kg) - kg");
	
	$field = &$form->addTextField('car_gewichte_gesamtgewicht');
    $field->setLabel("Zul. Gesamtgewicht - kg");
	
	$field = &$form->addTextField('car_gewichte_zuladung');
    $field->setLabel("Zuladung - kg");
	
	$field = &$form->addTextField('car_gewichte_achslast');
    $field->setLabel("Zul. Achslast vorn / hinten - kg");			
	$field->setSuffix('<br style="clear:both;" />');
	
	#############################################
	# Karosserie 
	$form->addFieldSet('Karosserie');
	
	$field = &$form->addTextField('car_karosserie_sitzbankaufgestellt');
    $field->setLabel("Sitzbank aufgestellt - l");

	$field = &$form->addTextField('car_karosserie_luftwiderstandsbeiwert');
    $field->setLabel("Luftwiderstandsbeiwert - cw");
	$field->setSuffix('<br style="clear:both;" />');
	
	#############################################
	# Motor 
	$form->addFieldSet('Motor');
	
	$field = &$form->addTextField('car_motor_leistung');
    $field->setLabel("Leistung - kW (PS) min-1");

	$field = &$form->addTextField('car_motor_emissionsklasse');
    $field->setLabel("Emissionsklasse");

	$field = &$form->addTextField('car_motor_kraftstoff');
    $field->setLabel("Kraftstoff - Oktan");

	$field = &$form->addTextField('car_motor_bauart');
    $field->setLabel("Bauart");

	$field = &$form->addTextField('car_motor_hubraum');
    $field->setLabel("Hubraum - cm&sup3;");

	$field = &$form->addTextField('car_motor_bohrung');
    $field->setLabel("Bohrung / Hub - mm");
	
	$field = &$form->addTextField('car_motor_max');
    $field->setLabel("Max. Drehmoment - Nm/min-1");
	$field->setSuffix('<br style="clear:both;" />');


	$form->show();
	
}

?>